﻿@{
    Layout = null;
}
@model  NB.MGJ.Model.CodeManage_GenCode
<style>
    .btn-success input[type="file"] {
        opacity: 0;
    }
</style>
<script src="~/Scripts/MGJJS/CodeManage/RowCodeListbox.js"></script>


<form id="form_editCode" role="form" onkeydown="if(event.keyCode==13){return false;}">
    <input type="hidden" name="PatchId" value="@Model.PatchId" />
    <input type="hidden" value="@Model.EnterpriseId" name="EnterpriseId" />
    <input type="hidden" value="@Model.ID" name="ID" />
    <div class="row">
        <div class="col-xs-2 col-md-2 text-right">
            <span class="red-700">*</span>公司名称：
        </div>
        <div class="col-xs-4 col-md-4">
            <input type="text" class="form-control" disabled="disabled" value="@Model.EnterpriseName" name="EnterpriseName" id="EnterpriseName" />
            @*@Html.DropDownList("EnterpriseId", null, new { @Modellass = "form-control",@disabled = "disabled "})*@
        </div>


        <div class="col-xs-2 col-md-2 text-right">
            <span class="red-700">*</span>生码类型：
        </div>
        <div class="col-xs-4 col-md-4">
            <input type="checkbox" name="CodeTypes" value="1" onchange="$.MGJ.RawCode.codebocx()" disabled="disabled" />
            <label for="">服务码</label>
            <input type="checkbox" name="CodeTypes" value="2" onchange="$.MGJ.RawCode.codebocx()" disabled="disabled" />
            <label for="">管理码</label>
            <input type="checkbox" name="CodeTypes" value="3" onchange="$.MGJ.RawCode.codebocx()" disabled="disabled" />
            <label for="">序列码</label>
            <input type="hidden" name="CodeType" id="CodeType" />
        </div>
    </div>
    <div class="row">
        <div class="col-xs-2 col-md-2 text-right">
            <span class="red-700">*</span>服务码位数：
        </div>
        <div class="col-xs-4 col-md-4">
            <input class="form-control" type="text" name="Anti_Fake_Num" id="Anti_Fake_Num" value="@Model.Anti_Fake_Num " disabled="disabled" />
        </div>
        <div class="col-xs-2 col-md-2  text-right">
            <span class="red-700">*</span>管理码位数：
        </div>
        <div class="col-xs-4 col-md-4">
            <input class="form-control" type="text" name="Logistics_Num" id="Logistics_Num" value="@Model.Logistics_Num " disabled="disabled" />
        </div>
    </div>
    <div class="row">
        <div class="col-xs-2 col-md-2 text-right">
            <span class="red-700">*</span>生码数量：
        </div>
        <div class="col-xs-4 col-md-4">
            <input class="form-control" type="text" name="Gen_Code_Nums" id="Gen_Code_Nums" value="@Model.Gen_Code_Nums " disabled="disabled" />
        </div>
        <div class="col-xs-2 col-md-2  text-right">
            产品批次：
        </div>
        <div class="col-xs-4 col-md-4">
            <select class="form-control EmptyValidationText" id="ProductBatchId" name="ProductBatchId"></select>
            @*Html.DropDownList("ProductBatchId", null, new { @Model class = "form-control" })*@
        </div>
    </div>
    <div class="row">
        <div class="col-xs-2 col-md-2 text-right">
            产品名称：
        </div>
        <div class="col-xs-4 col-md-4">
            <select class="form-control EmptyValidationText" id="ProductId" name="ProductId"></select>
        </div>
        <div class="col-xs-2 col-md-2  text-right">
            产品类型：
        </div>
        <div class="col-xs-4 col-md-4">
            <select class="form-control EmptyValidationText" id="TypeId" name="TypeId"></select>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-2 col-md-2 text-right">
            网站查询：
        </div>
        <div class="col-xs-4 col-md-4">
            <input class="form-control value" type="text" name="Query_Result_Content" id="Query_Result_Content" value="@Model.Query_Result_Content " />
        </div>
        <div class="col-xs-2 col-md-2  text-right">
            短信查询：
        </div>
        <div class="col-xs-4 col-md-4">
            <input class="form-control value" type="text" name="Query_Message_Content" id="Query_Message_Content" value="@Model.Query_Message_Content " />
        </div>
    </div>
    <div class="row">
        <div class="col-xs-2 col-md-2 text-right">
            电话查询：
        </div>
        <div class="col-xs-4 col-md-4">
            <input class="form-control value" type="text" name="Query_Tel_Content" id="Query_Tel_Content" value="@Model.Query_Tel_Content " />
        </div>

        <div class="col-xs-2 col-md-2 text-right">
            生码批次：
        </div>
        <div class="col-xs-4 col-md-4">
            <input class="form-control" readonly="readonly" name="Batch" value="@Model.Batch" />
        </div>
    </div>
    <div class="row">



        <div class="col-xs-2 col-md-2 text-right">
            激活方式：
        </div>
        <div class="col-xs-4 col-md-4">
            @Html.RadioButton("Status", 1, Model.Status == 1 ? true : false)立即生效
            @Html.RadioButton("Status", 2, Model.Status == 2 ? true : false)出库后生效
        </div>
        <div class="col-xs-2 col-md-2 text-right">
            数据期限：
        </div>
        <div class="col-xs-4 col-md-4">
            @Html.RadioButton("ExpiryDate", 1, Model.ExpiryDate == "1" ? true : false)无限期
            @Html.RadioButton("ExpiryDate", 2, Model.ExpiryDate == "2" ? true : false)3年
            @Html.RadioButton("ExpiryDate", 3, Model.ExpiryDate == "3" ? true : false)2年
            @Html.RadioButton("ExpiryDate", 4, Model.ExpiryDate == "4" ? true : false)1年
        </div>
    </div>

    <div class="row">
        <div class="col-xs-2 col-md-2 text-right">
            企业名称：
        </div>
        <div class="col-xs-4 col-md-4">
            <input class="form-control" type="text" name="EnterpriseUse" id="EnterpriseUse" onchange="check(this)" value="@Model.EnterpriseUse" />
        </div>

        <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 text-right">
            标签图片：
        </div>
        <div id="thelist" class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
            <label id="picker" style="background: url('/Content/webImgs/upLogo/cp_img_tj.png' );background-size:100% 100%;width:60px;height:60px;border-radius:4px;">
            </label>
            <input type="hidden" name="LabelImage" id="LabelImage" value="@Model.LabelImage" />
        </div>
    </div>
</form>
 
<script>
    function check(_this) {
        var ename=$("#EnterpriseUse").val();
        $(".value").val('您好！您所查询的是' + ename + '生产的品牌产品，是正牌产品的标识，欢迎您再次选购！');
        $(".value").attr("title", '您好！您所查询的是' + ename + '生产的品牌产品，是正牌产品的标识，欢迎您再次选购！');
    }
 
    $(function () { 
        $.MGJ.RawCode.Ajax_PoductNameList(@Model.EnterpriseId,@Model.ProductId);

        $.MGJ.RawCode.Ajax_ProductTypeList(@Model.ProductId);
        $.MGJ.RawCode.Ajax_BatchList(@Model.ProductId);
        var CodeType = "@Model.CodeType";
        var temp = CodeType.split(",");
        for (i = 0; i < temp.length ; i++) {
            $("input[name ='CodeTypes'][value='" + temp[i] + "']").attr("checked", true);
        }
    });

    //图片上传
    $(function () {
        var isUpload = 0;
        if ($("#LabelImage").val() != '') {
            $('#picker').hide();
            $('#thelist').prepend("<div class='img-thumbnail'><img src='" + $("#LabelImage").val() + "' style='width:60px;height:60px' /></div>");
            $('#thelist > .img-thumbnail').eq(0).mouseenter(function () {
                var url = $(this).find('img').attr('src');
                $(this).attr('name', url).find('img').css({ 'width': '60px', 'height': '60px' }).attr('src', '/Content/webImgs/upLogo/cp_img_sc.png');
            }).mouseleave(function () {
                var url = $(this).attr('name');
                $(this).find('img').attr('src', url);
            }).click(function () {
                $(this).remove();
                $('#picker').css('display', 'inline-block');
                isUpload = 0;
                $("#LabelImage").val("");
            });
        }
        else {
            $('#picker').mouseenter(function () {
                $(this).css({ 'background': 'url("/Content/webImgs/upLogo/cp_img_tj_a.png")', 'backgroundSize': '100% 100%' });
            }).mouseleave(function () {
                $(this).css({ 'background': 'url("/Content/webImgs/upLogo/cp_img_tj.png")', 'backgroundSize': '100% 100%' });
            });
        }

        var uploader2 = WebUploader.create({
            server:  '/Upload/Upload/',
            pick: {
                id: '#picker',
                multiple: false
            },
            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,bmp,png',
                mimeTypes: 'image/jpg,image/jpeg,image/png'
            },
            resize: false
        });
        upImg(uploader2, '#picker');
        function upImg(item, selector) {
            // 当有文件添加进来的时候
            item.on('fileQueued', function (file) {
                isUpload = 1;
                var $li = $(
                                '<div  id="' + file.id + '" class="img-thumbnail">' +
                                '<img alt="null"/>' +
                                '</div>'
                        ),
                        $img = $li.find('img');
                // $list为容器jQuery实例
                $(selector).parent().prepend($li);
                item.makeThumb(file, function (error, src) {
                    if (error) {
                        $img.replaceWith('<span>不能预览</span>');
                        return;
                    }
                    $img.attr('src', src);
             
                
                }, 60, 60);
                $('#thelist > .img-thumbnail').eq(0).mouseenter(function () {
                    var url = $(this).find('img').attr('src');
                    $(this).attr('name', url).find('img').css({ 'width': '60px', 'height': '60px' }).attr('src', '/Content/webImgs/upLogo/cp_img_sc.png');
                }).mouseleave(function () {
                    var url = $(this).attr('name');
                    $(this).find('img').attr('src', url);
                }).click(function () {
                    $(this).remove();
                    $('#picker').css('display', 'inline-block');
                });

                $('#picker').css('display', 'none');


                item.upload();
            });
            // 文件上传过程中创建进度条实时显示。
            item.on('uploadProgress', function (file, percentage) {
                var $li = $('#' + file.id),
                        $percent = $li.find('.progress span');

                // 避免重复创建
                if (!$percent.length) {
                    $percent = $('<p class="progress"><span></span></p>')
                            .appendTo($li)
                            .find('span');
                }

                $percent.css('width', percentage * 100 + '%');
            });

            // 文件上传成功，给item添加成功class, 用样式标记上传成功。
            item.on('uploadSuccess', function (file, result) {
                $('#LabelImage').val(result._raw.substring(5));
            });

            // 文件上传失败，显示上传出错。
            item.on('uploadError', function (file,r) {
                var $li = $('#' + file.id),
                        $error = $li.find('div.error');
                // 避免重复创建
                if (!$error.length) {
                    $error = $('<div class="error" style="position: absolute;font-size: 14px;top:10px;left: 74px;color:red"></div>').appendTo($li);
                }
              
                $error.text("上传失败");
              
            });

            // 完成上传完了，成功或者失败，先删除进度条。
            item.on('uploadComplete', function (file) {
                $('#' + file.id).find('.progress').remove();
            });
         
        }

      

    })
            

    //$('#form_editcode').bootstrapvalidator({
    //    group: '.col-xs-4.col-md-4',
    //    fields: {
    //        EnterpriseUse: {
    //            validators: {
    //                notEmpty: {
    //                    message: '请输入企业名称'
    //                },
    //            }
    //        },
           
    //    }
    //});
</script>